/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



public class SIngresoMP extends HttpServlet {


    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {

            int mp_id;
            String mp_provid;
            String mp_nombre;
            String mp_descripcion;
            String mp_tamano;
            String mp_tipo;
            String mp_precio;
            IngresoDatosMaestros InMP = new IngresoDatosMaestros ();
            Correlativos CMP = new Correlativos();
            CMP.cMateriaPrima();
            mp_id = CMP.CMP + 1;
            mp_provid = request.getParameter("combo_Prov");
            mp_nombre = request.getParameter("mp_nombre");
            mp_descripcion = request.getParameter("mp_desc");
            mp_tamano = request.getParameter("mp_tamano");
            mp_tipo = request.getParameter("combo_TipoMP");
            mp_precio = request.getParameter("mp_precio");

            InMP.GrabarDatos_MP(mp_id,mp_provid,mp_nombre, mp_descripcion, mp_tamano, mp_tipo, "0", mp_precio);

            out.println("<html>");
            out.println("<head>");
            out.println("<meta http-equiv='Refresh' content='0;url=In-MateriaPrima_Confirmacion.html'>");
            out.println("</head>");
            out.println("</html>");



        } finally {
            out.close();
        }
    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
